using System;
using System.ComponentModel;
using System.Drawing;
using System.Xml.Serialization;

namespace com.exceptionalsoftware.spacetime.KML
{
	[Serializable()]
    [XmlType(TypeName = "ColorStyleType")]
    [XmlInclude(typeof(LineStyle))]
    [XmlInclude(typeof(PolyStyle))]
    [XmlInclude(typeof(IconStyle))]
    [XmlInclude(typeof(LabelStyle))]
	public class ColorStyle : ObjectType
	{
        private ColorModeEnum colorModeField;
        private KMLColor colorField;

        public ColorStyle()
		{
            this.colorModeField = ColorModeEnum.Normal;
            this.colorField = new KMLColor("ffffffff");
		}

        [XmlIgnore()]
        public Color Color
        {
            get { return this.colorField.Color; }
            set { this.colorField = new KMLColor(value); }
        }

        [XmlIgnore()]
        public string ColorString
        {
            get { return this.colorField.ToString(); }
            set { this.colorField = new KMLColor(value); }
        }

        [XmlElement(ElementName = "color", DataType = "hexBinary", Type = typeof(byte[]))]
        public byte[] ColorComponents
        {
            get { return this.colorField.ToByteArray(); }
            set { this.colorField = new KMLColor(value); }
        }

        [XmlElement(ElementName = "colorMode", Type = typeof(ColorModeEnum))]
        [DefaultValue(ColorModeEnum.Normal)]
        public ColorModeEnum ColorMode
        {
            get { return this.colorModeField; }
            set { this.colorModeField = value; }
        }
    }

    [XmlType(TypeName = "colorModeEnum")]
    public enum ColorModeEnum
    {
        [XmlEnum(Name = "normal")]
        Normal,

        [XmlEnum(Name = "random")]
        Random
    }
}